package per.zhang.vaccinesys.serverConsumer.dto.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.format.annotation.DateTimeFormat;
import per.zhang.vaccinesys.serverConsumer.entity.Appointment;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;

/**
 * @auther zhang
 * @ TO DO
 * @creatTime 2021/1/26 17:47
 **/
@Data
@ApiModel(value="AppointmentRequsetDTO")
@NoArgsConstructor
@AllArgsConstructor
public class AppointmentRequestDTO extends PageDTO {



    /**
     * 预约id
     */
    @ApiModelProperty(value = "预约id",name = "appointmentId",dataType = "Integer")
    private Integer appointmentId;

    /**
     * 用户id
     */
    @ApiModelProperty(value = "用户id",name = "userId",dataType = "String")
    private String userId;

    /**
     * 预约人名字
     */
    @ApiModelProperty(value = "预约人名字",name = "userName",dataType = "String")
    private String userName;

    /**
     * 用户联系方式
     */
    @ApiModelProperty(value = "用户联系方式",name = "callphone",dataType = "String")
    private String callphone;

    /**
     * 疫苗id
     */
    @ApiModelProperty(value = "疫苗id",name = "vaccineId",dataType = "Integer")
    private Integer vaccineId;

    /**
     * 预约时间
     */
    @DateTimeFormat(pattern = "YYYY-MM-DD hh:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "预约时间",name = "appointmentTime",dataType = "LocalDateTime",example = "2020-1-26 00:00:00")
    private Date appointmentTime;

    /**
     * 预约状态，0表示已预约，1表示已接种，2表示已取消
     */
    @ApiModelProperty(value = "预约状态，0表示已预约，1表示已接种，2表示已取消",name = "state",dataType = "String")
    private String state;

    public Appointment TranToAppointment(Appointment appointment) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        PropertyUtils.copyProperties(appointment,this);
        return appointment;
    }

}
